/*
 * rom_hal.h
 *
 * Created: 8/16/2013 10:57:11 AM
 *  Author: Ken Arok
 
 * Created: 8/16/2013 10:24:36 AM
 *  Author: Ken Arok
 *
 *      Revision history:
 *      ---------------------------------------------------------
 *      Date			|	Revised by		|	Description
 *      ---------------------------------------------------------
 *      1. Aug 16, 2013	|	Yosef			| New establishment
 *
 *
 *
 * \brief Hardware Abstraction Layer of Read Only Memory (EEPROM or Flash ROM).
 *
 * Copyright (c) 2013 PT Hanindo Automation Solutions. All rights reserved.
 *
 */

#include "config_board.h"

#if BOARD_1_0_USED

#ifndef ROM_HAL_H_
#define ROM_HAL_H_

#include "board.h"

#ifdef __cplusplus
extern "C" {
#endif

#if ROM_PART_NAME_SST25VF080B
/* ID of this serial flash chip memory. */
#define ROM_ID		0x00BF258E
#endif

/** \brief Initialize serial flash.
 */
extern void rom_init(void);

/** \brief Read identification register of serial flash.
 *
 * \return ID_REG	32 bit identification register.
 *
 */
extern uint32_t rom_read_id(void);

/** \brief Read data byte from SST25VF080B.
 *
 * \param _start_addr	Start address in the memory want to be read.
 * \param _pbuf			Pointer to the buffer where data will be copied.
 * \param _len			Number of byte data want to be read.
 *
 * \return Status
 *	\retval	0	Success.
 *	\retval	-1	Failed.
 *
 */
extern char rom_read(uint32_t _start_addr, void *_pbuf, uint32_t _len);

/** \brief Write data to serial flash memory.
 *
 * \param _star_addr	Start of address to be programmed.
 * \param _pbuf_data	Pointer to the data want to be programmed.
 * \param _len			Number of bytes of data want to be programmed.
 *
 * \return Status
 *	\retval 0	Success.
 *	\retval	-1	Failed.
 *
 */
extern char rom_write(uint32_t _star_addr, const void *_pbuf, uint32_t _len);

/** \brief Erase 32 KB block memory on SST25VF080B.
 *
 * \param _block_addr	Block address want to be erased.
 *
 */
extern void rom_erase_block(uint32_t _block_addr);



#ifdef __cplusplus
}
#endif

#endif /* ROM_HAL_H_ */

#endif /* BOARD_1_0_USED */
